package sk.fiit.icp.components;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
	public static String dateToSQLString(Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd hh-mm-ss" );
		return formatter.format( date );
	}

	public static String dateToJSString(Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm" );
		return formatter.format( date );
	}

	public static Date JSDateStringToDate(String date) {
		SimpleDateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy HH:mm" );
		try {
			return formatter.parse( date );
		} catch ( ParseException e ) {
			new Exception( "Can't convert JS time to Java Date object!" );
			e.printStackTrace();
		}
		return null;
	}
}
